<template>
    <div class="type-swiper-game">
        <div class="item-nav" v-if="detail.label">
            <div class="nav-left"></div>
            <div class="nav-center">{{detail.label}}</div>
            <div class="nav-right">更多</div>
        </div>
        <el-carousel class="swiper" arrow="always" indicator-position="none" :autoplay="false" height="222px" v-if="detail._contentType === 2">
            <el-carousel-item v-for="(item, index) in detail.elements" :key="index">
                <div class="swiper-item" style="height:160px;">
                    <img :src="item.cover + '?x-oss-process=image/quality,q_50'" alt="">
                    <div class="video-icon-box">
                        <div class="icon"></div>
                        <div class="time">03:12</div>
                    </div>
                </div>
                <moduleGameBar :data="item" :showTitle="detail.showTitle" :showCategory="detail.showCategory" :showButton="detail.showButton"/>
            </el-carousel-item>
        </el-carousel>
        <el-carousel class="swiper" arrow="always" indicator-position="none" :autoplay="false" height="222px" v-else>
            <el-carousel-item v-for="(item, index) in detail.elements" :key="index">
                <div class="swiper-item" style="height:160px;">
                    <img :src="item.url + '?x-oss-process=image/quality,q_50'" alt="">
                </div>
                <moduleGameBar :data="item" :showTitle="detail.showTitle" :showCategory="detail.showCategory" :showButton="detail.showButton"/>
            </el-carousel-item>
        </el-carousel>
    </div>
</template>

<script>
export default {
    // 轮播+游戏信息 4100
    name: 'model4100',
    props: ['data'],
    data () {
        return {
            detail: {
                _contentType: 1,
                showTitle: 1,
                showCategory: 0,
                showButton: 0,
                label: '',
                elements: [
                    {
                        url: '',
                        appIcon: '',
                        appName: '游戏名称',
                        appTitle: '副标题',
                        appScore: 9.9,
                        cover: ''
                    },
                    {
                        url: '',
                        appIcon: '',
                        appName: '游戏名称',
                        appTitle: '副标题',
                        appScore: 9.9,
                        cover: ''
                    },
                    {
                        url: '',
                        appIcon: '',
                        appName: '游戏名称',
                        appTitle: '副标题',
                        appScore: 9.9,
                        cover: ''
                    }
                ]
            }
        }
    },
    created () {
        if (this.data) {
            this.detail.label = this.data.label
        }
        if (this.data && this.data.elements && this.data.elements.length) {
            this.detail = this.data
        }
    },
    watch: {
        data: {
            handler: function (val) {
                if (val) {
                    this.detail.label = val.label
                }
                if (val && val.elements && val.elements.length) {
                    this.detail = val
                }
            },
            deep: true
        }
    }
}
</script>

<style lang="scss">
    .type-swiper-game {
        padding: 18px 0;
        border-bottom: 1px solid rgba(228,228,228,1);
        .item-nav {
            display: flex;
            height: 16px;
            align-items: center;
            padding: 0 16px;
            margin-bottom: 12px;
            .nav-left {
                width:4px;
                height:16px;
                background:rgba(0,191,60,1);
                border-radius:3px;
                margin-right: 8px;
            }
            .nav-center {
                flex: 1;
                font-size:16px;
                font-family:SourceHanSansCN-Medium,SourceHanSansCN;
                font-weight:500;
                color:rgba(28,32,44,1);
            }
            .nav-right {
                margin-right: 4px;
                display: flex;
                align-items: center;
                font-size:12px;
                font-family:SourceHanSansCN-Normal,SourceHanSansCN;
                font-weight:400;
                color:rgba(28,32,44,0.6);
                cursor: pointer;
                &::after {
                    content: '';
                    width: 7px;
                    height: 7px;
                    margin-left: 4px;
                    border-right: 2px solid #1C202C;
                    border-bottom: 2px solid #1C202C;
                    transform: rotate(-45deg);
                }
            }

        }
        .swiper {
            .swiper-item {
                position: relative;
                top: 0;
                left: 0;
                z-index: 1;
                border-radius: 6px;
                width: 328px;
                height: 100%;
                margin: 0 auto;
                overflow: hidden;
                background-color: #ddd;
                > img {
                    width: 100%;
                    height: 100%;
                }
                .video-icon-box {
                    position: absolute;
                    top: 57px;
                    left: 50%;
                    transform: translateX(-50%);
                    z-index: 1;
                    .icon {
                        width: 48px;
                        height: 48px;
                        background-image: url('./img/video.png');
                        background-size: 100% 100%;
                    }
                    .time {
                        text-align: center;
                        margin-top: 6px;
                        font-size:12px;
                        font-family:Roboto-Regular,Roboto;
                        font-weight:400;
                        color:rgba(255,255,255,1);
                    }
                }
            }
        }
    }
</style>
